package me.khrystal.rxnews.utils;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;

/**
 * usage:
 * author: kHRYSTAL
 * create time: 16/4/13
 * update time:
 * email: 723526676@qq.com
 */
public class ThemeUtil {

    public static int getColor(Context context,int attrColor){
        int[] attrs = {attrColor};
        TypedArray ta = context.getTheme().obtainStyledAttributes(attrs);
        int color = ta.getColor(0,0);
        ta.recycle();
        return color;
    }

    public static ColorStateList getColorStateList(Context context,int attrColorStateList){
        int[] attrs = {attrColorStateList};
        TypedArray ta = context.getTheme().obtainStyledAttributes(attrs);
        ColorStateList colorStateList = ta.getColorStateList(0);
        ta.recycle();
        return colorStateList;
    }
}
